package top.anydata.lifeofcode.lifesystem.dao.sys.user;

import io.lettuce.core.dynamic.annotation.Param;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import top.anydata.lifeofcode.lifesystem.entity.sys.user.SysAuthPermissionEntity;
import top.anydata.lifeofcode.lifesystem.entity.sys.user.SysAuthRolePermissionEntity;

import java.util.List;

@Repository
public interface ISysAuthRolePermissionRepository extends JpaRepository<SysAuthRolePermissionEntity, Integer> {

    void deleteByRoleIdAndPermissionId(int roleId, int permissionId);

    List<SysAuthRolePermissionEntity> findPermissionsByRoleId(@Param("roleId") int roleId);

    @Override
    @Modifying
    @Query("update SysAuthRolePermissionEntity s set s.isDeleted = 1 where s.id = ?1")
    void deleteById(Integer integer);
}
